/**
 * 留言表单用 js
 * @author yulipu
 */
/**
 * faces
 * @param id 引发 onfocus 事件的容器 id
 * @param showId 显示表情的容器 id
 */
function YFace(id, showId) {
	this.id = id;
	this.showId = showId;
	this.doc = document;
	this.basePath = Y._ROOT_ + "/Public/images/smiles/";
	this.faces = [
		"icon_wink.gif",
		"icon_arrow.gif",
		"icon_biggrin.gif",
		"icon_confused.gif",
		"icon_cool.gif",
		"icon_cry.gif",
		"icon_eek.gif",
		"icon_evil.gif",
		"icon_exclaim.gif",
		"icon_idea.gif",
		"icon_lol.gif",
		"icon_mad.gif",
		"icon_mrgreen.gif",
		"icon_neutral.gif",
		"icon_question.gif",
		"icon_razz.gif",
		"icon_rolleyes.gif",
		"icon_redface.gif",
		"icon_sad.gif",
		"icon_smile.gif",
		"icon_surprised.gif",
		"icon_twisted.gif"
	];
	
	this.init = function() {
		var _this = this;
		var obj = this.doc.getElementById(this.id);
		obj.onfocus = function() {
			var tmp = '';
			var o = _this.doc.getElementById(_this.showId);
			if(o.innerHTML == '') {
				for(var i=0,len=_this.faces.length; i<len; i++) {
					tmp = _this.faces[i].substring(_this.faces[i].indexOf("_")+1, _this.faces[i].indexOf("."));
					o.innerHTML += "<a onclick=\"document.getElementById('"+ _this.id +"').value+='["+ tmp +"]';\"><img src=\""+ _this.basePath + _this.faces[i] +"\"/></a>";	
				}
			}
		};
		obj = null;
	};
}

